<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>

<body>
  <script>
    function deepClone(obj) {
      if (typeof obj !== 'object' || obj === null) {
        return obj
      }

      let result
      if (obj instanceof Array) {
        result = []
      } else {
        result = {}
      }

      for (let key in obj) {
        if (obj.hasOwnProperty(key)) {
          result[key] = deepClone(obj[key])
        }
      }

      return result
    }

    let obj = {
      name: 'san',
      car: [1,2,1,3],
      child: {
        name: 'si'
      }
    }
    let res = deepClone(obj)
  </script>
</body>

</html>